home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
bathints.zip
/
BH_09.DOC
< prev
next >
Wrap
Text File
|
1988-10-16
|
13KB
|
272 lines
BAT-HINT # 9
**************************************************************************
from the BATHINTS library... part of the BATPOWER CONFERENCE from:
THE PAINFRAME OPUS/FIDO 261/1004
Baltimore, Maryland 1-301-488-7461
**************************************************************************
Errorlevels, Scan Codes and the Keyboard
Some programs assign a value to the DOS variable ERRORLEVEL. Indeed, only
a program can place a value for errorlevel in memory (though of course the
ERRORLEVEL is altered when you restart your computer). Do not confuse
ERRORLEVEL with replaceable parameters or environmental variables, for it
is neither. Its value is stored in its own register and is only one byte
in size. The value of the ERRORLEVEL variable can be examined and tested
with the IF and ERRORLEVEL subcommands in batch files... and since the
variable is not altered with testing, repetitive tests can be performed.
Tests for errorlevels are always constructed from highest to lowest in
batch files, since the statement:
if errorlevel x {perform command}
is true if the errorlevel value "x" is equal to or greater than value "x".
Conversely, the statement:
if not errorlevel x {perform command}
is true if the errorlevel is less than the value "x". These two IF
statements can be nested to test the value of ERRORLEVEL for a specific
value as shown below:
if errorlevel x if not errorlevel x+1 {perform command}
where "x" is any value from 0 to 254 and "x+1" is any value from 1 to 255
when the if errorlevel statement is nested as shown above.
Very few DOS commands place a value in ERRORLEVEL (for example, BACKUP and
RESTORE return 0 upon failure and 1 upon success), but several public
domain and copywrited programs are available to make ERRORLEVEL testing
useful to the user. One such program available in BATPOWER files is
KEY.COM. Read the documentation file that accompanies KEY.COM for details
on its use. To assist in the use of KEY.COM, examine the table below:
Table 1. The 256 Characters of the IBM Extended Character Set
╔═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╗
║000│nul║032│spc║064│ @ ║096│ ` ║128│ Ç ║160│ á ║192│ └ ║224│ α ║
║001│soh║033│ ! ║065│ A ║097│ a ║129│ ü ║161│ í ║193│ ┴ ║225│ ß ║
║002│stx║034│ " ║066│ B ║098│ b ║130│ é ║162│ ó ║194│ ┬ ║226│ Γ ║
║003│etx║035│ # ║067│ C ║099│ c ║131│ â ║163│ ú ║195│ ├ ║227│ π ║
║004│eot║036│ $ ║068│ D ║100│ d ║132│ ä ║164│ ñ ║196│ ─ ║228│ Σ ║
║005│enq║037│ % ║069│ E ║101│ e ║133│ à ║165│ Ñ ║197│ ┼ ║229│ σ ║
║006│ack║038│ & ║070│ F ║102│ f ║134│ å ║166│ ª ║198│ ╞ ║230│ µ ║
║007│bel║039│ ' ║071│ G ║103│ g ║135│ ç ║167│ º ║199│ ╟ ║231│ τ ║
║008│bs ║040│ ( ║072│ H ║104│ h ║136│ ê ║168│ ¿ ║200│ ╚ ║232│ Φ ║
║009│tab║041│ ) ║073│ I ║105│ i ║137│ ë ║169│ ⌐ ║201│ ╔ ║233│ Θ ║
║010│lf ║042│ * ║074│ J ║106│ j ║138│ è ║170│ ¬ ║202│ ╩ ║234│ Ω ║
║011│vt ║043│ + ║075│ K ║107│ k ║139│ ï ║171│ ½ ║203│ ╦ ║235│ δ ║
║012│ff ║044│ , ║076│ L ║108│ l ║140│ î ║172│ ¼ ║204│ ╠ ║236│ ∞ ║
║013│ret║045│ - ║077│ M ║109│ m ║141│ ì ║173│ ¡ ║205│ ═ ║237│ φ ║
║014│so ║046│ . ║078│ N ║110│ n ║142│ Ä ║174│ « ║206│ ╬ ║238│ ε ║
║015│si ║047│ / ║079│ O ║111│ o ║143│ Å ║175│ » ║207│ ╧ ║239│ ∩ ║
║016│dle║048│ 0 ║080│ P ║112│ p ║144│ É ║176│ ░ ║208│ ╨ ║240│ ≡ ║
║017│dc1║049│ 1 ║081│ Q ║113│ q ║145│ æ ║177│ ▒ ║209│ ╤ ║241│ ± ║
║018│dc2║050│ 2 ║082│ R ║114│ r ║146│ Æ ║178│ ▓ ║210│ ╥ ║242│ ≥ ║
║019│dc3║051│ 3 ║083│ S ║115│ s ║147│ ô ║179│ │ ║211│ ╙ ║243│ ≤ ║
║020│dc4║052│ 4 ║084│ T ║116│ t ║148│ ö ║180│ ┤ ║212│ ╘ ║244│ ⌠ ║
║021│nak║053│ 5 ║085│ U ║117│ u ║149│ ò ║181│ ╡ ║213│ ╒ ║245│ ⌡ ║
║022│syn║054│ 6 ║086│ V ║118│ v ║150│ û ║182│ ╢ ║214│ ╓ ║246│ ÷ ║
║023│etb║055│ 7 ║087│ W ║119│ w ║151│ ù ║183│ ╖ ║215│ ╫ ║247│ ≈ ║
║024│can║056│ 8 ║088│ X ║120│ x ║152│ ÿ ║184│ ╕ ║216│ ╪ ║248│ ° ║
║025│em ║057│ 9 ║089│ Y ║121│ y ║153│ Ö ║185│ ╣ ║217│ ┘ ║249│ ∙ ║
║026│sub║058│ : ║090│ Z ║122│ z ║154│ Ü ║186│ ║ ║218│ ┌ ║250│ · ║
║027│esc║059│ ; ║091│ [ ║123│ { ║155│ ¢ ║187│ ╗ ║219│ █ ║251│ √ ║
║028│fs ║060│ < ║092│ \ ║124│ | ║156│ £ ║188│ ╝ ║220│ ▄ ║252│ ⁿ ║
║029│gs ║061│ = ║093│ ] ║125│ } ║157│ ¥ ║189│ ╜ ║221│ ▌ ║253│ ² ║
║030│rs ║062│ > ║094│ ^ ║126│ ~ ║158│ ₧ ║190│ ╛ ║222│ ▐ ║254│ ■ ║
║031│us ║063│ ? ║095│ _ ║127│ ║159│ ƒ ║191│ ┐ ║223│ ▀ ║255│ ║
╚═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╝
The first 128 characters (0 to 127) are the standard ASCII character set
and the last 128 characters (128 to 255) comprise the IBM extended
character set. The first 32 characters (0 to 31) are the control
characters, explained in more detail in table 2.
Table 2. The Control Characters
╔═══╤══════╦═══╤══════╦═══╤══════╦═══╤══════╗
║000│ N/A ║008│ctrl-h║016│ctrl-p║024│ctrl-x║
║001│ctrl-a║009│ctrl-i║017│ctrl-q║025│ctrl-y║
║002│ctrl-b║010│ctrl-j║018│ctrl-r║026│ctrl-z║
║003│ctrl-c║011│ctrl-k║019│ctrl-s║027│ctrl-[║
║004│ctrl-d║012│ctrl-l║020│ctrl-t║028│ctrl-\║
║005│ctrl-e║013│ctrl-m║021│ctrl-u║029│ctrl-]║
║006│ctrl-f║014│ctrl-n║022│ctrl-v║030│ctrl-^║
║007│ctrl-g║015│ctrl-o║023│ctrl-w║031│ctrl-_║
╚═══╧══════╩═══╧══════╩═══╧══════╩═══╧══════╝
Notice that ctrl-g (code 007) is the bell. Entering the follwing statement
ina batch file will cause the speaker to beep:
echo ctrl-g
The line above is entered by typing ECHO then leaving a space then holding
down the ctrl key and pressing the letter g. You can use this technique to
place a beep in your batch files at discrete points of processing.
You should also note from tables 1 and 2 the codes for certain important
keys: codes 28, 29, 30 and 31 are the right, left, up and down cursor
control keys respectively; code 13 is a carriage return; code 8 is the
backspace key; code 27 is the escape key.
Keyboard combinations like shift-F9, alt-J, and ctrl-F7 also have scan
codes... as do all the possible key combinations. Using KEY.COM or other
programs, you could figure these codes out yourself... just as with the 256
characters of the extended character set, but they are shown below for
convenience. Note that all of these extended codes are composed of two
numbers, the first of which is always 0.
Table 3. Codes for Function and Other Keys Used Alone or in
Combination with the ALT, CTRL or SHIFT Keys
╔═════╤═════╤═════╤═════╤═════╦═════╤═════╤═════╤═════╤═════╗
║ KEY │ │ ALT │CTRL │SHIFT║ KEY │ │ ALT │CTRL │SHIFT║
╠═════╪═════╪═════╪═════╪═════╬═════╪═════╪═════╪═════╪═════╣
║ TAB │ 9 │ │ │0;15 ║ r │ 82 │0;19 │ 18 │ 114 ║
║ - │ 45 │0;130│ │ 95 ║ s │ 83 │0;31 │ 19 │ 115 ║
║ 0 │ 48 │0;129│ │ 41 ║ t │ 84 │0;20 │ 20 │ 116 ║
║ 1 │ 49 │0;120│ │ 33 ║ u │ 85 │0;22 │ 21 │ 117 ║
║ 2 │ 50 │0;121│ │ 64 ║ v │ 86 │0;47 │ 22 │ 118 ║
║ 3 │ 51 │0;122│ │ 35 ║ w │ 87 │0;17 │ 23 │ 119 ║
║ 4 │ 52 │0;123│ │ 36 ║ x │ 88 │0;45 │ 24 │ 120 ║
║ 5 │ 53 │0;124│ │ 37 ║ y │ 89 │0;21 │ 25 │ 121 ║
║ 6 │ 54 │0;125│ │ 94 ║ z │ 90 │0;44 │ 26 │ 122 ║
║ 7 │ 55 │0;126│ │ 38 ║ F1 │0;59 │0;104│0;94 │0;84 ║
║ 8 │ 56 │0;127│ │ 42 ║ F2 │0;60 │0;105│0;95 │0;85 ║
║ 9 │ 57 │0;128│ │ 40 ║ F3 │0;61 │0;106│0;96 │0;86 ║
║ = │ 61 │0;131│ │ 43 ║ F4 │0;62 │0;107│0;97 │0;87 ║
║ a │ 65 │0;30 │ 1 │ 97 ║ F5 │0;63 │0;108│0;98 │0;88 ║
║ b │ 66 │0;48 │ 2 │ 98 ║ F6 │0;64 │0;109│0;99 │0;89 ║
║ c │ 67 │0;46 │ 3 │ 99 ║ F7 │0;65 │0;110│0;100│0;90 ║
║ d │ 68 │0;32 │ 4 │ 100 ║ F8 │0;66 │0;111│0;101│0;91 ║
║ e │ 69 │0;18 │ 5 │ 101 ║ F9 │0;67 │0;112│0;102│0;92 ║
║ f │ 70 │0;33 │ 6 │ 102 ║ F10 │0;68 │0;113│0;103│0;93 ║
║ g │ 71 │0;34 │ 7 │ 103 ║HOME │0;71 │ │0;119│ 55 ║
║ h │ 72 │0;35 │ 8 │ 104 ║ UP │0;72 │ │